## R Code for Addtl Study, Immigration Data ##

# Load HealthCareImmigrationData.csv #
AllExps <- read.table(file.choose(), header = TRUE, sep = ",")

# Isolate Immigration Data
AllExps$Imm <- 0
AllExps$Imm[!is.na(AllExps$Q42)] <- 1
AllExps$Imm[!is.na(AllExps$Q39)] <- 1

Imm <- AllExps[which(AllExps$Imm == 1), ]

# Treat coded so that Episodic = 1, Thematic = 0
Imm$Treat <- ifelse(!is.na(Imm$Q39), 0, 1)
table(Imm$Treat)

# High numbers mean more extreme
Imm$Attitude <- ifelse(!is.na(Imm$Q42), Imm$Q42, Imm$Q39)
table(Imm$Attitude)
Imm$ImmAgree <- ifelse(Imm$Attitude < 4, 1, 0)
table(Imm$ImmAgree)

Imm$AttitudeEx <- abs(4 - Imm$Attitude) 
table(Imm$AttitudeEx)
Imm$AttitudeEx <- Imm$AttitudeEx/3
table(Imm$AttitudeEx)

# High numbers mean more important
Imm$Importance <- ifelse(!is.na(Imm$Q43), Imm$Q43, Imm$Q40)
Imm$Importance <- 5 - Imm$Importance
table(Imm$Importance)
Imm$Importance <- Imm$Importance/4
table(Imm$Importance)

# High numbers mean more salient
Imm$Salience <- 5 - Imm$Q11
table(Imm$Salience)
Imm$Salience <- Imm$Salience/4
table(Imm$Salience)

# High means more connected to core beliefs, right & wrong
Imm$Moral1 <- 5 - Imm$Q12
Imm$Moral2 <- 5 - Imm$Q13
Imm$MoralConv <- Imm$Moral1 + Imm$Moral2
table(Imm$MoralConv)
Imm$MoralConv <- Imm$MoralConv/8
table(Imm$MoralConv)

Imm$Anger <- Imm$Q29_1 - 1
Imm$Disgust <- Imm$Q29_2 - 1
Imm$Sadness <- Imm$Q29_3 - 1
Imm$Anxiety <- Imm$Q29_4 - 1

Imm$AllEmo <- Imm$Anger + Imm$Disgust + 
  Imm$Sadness + Imm$Anxiety

emodat <- c("Anger", "Disgust",
            "Sadness", "Anxiety")

emodata <- Imm[emodat]

emodata <- na.omit(emodata)

# Cronbach's alpha
library(psych)
alpha(emodata) # alpha = .89

Imm$ImmMoralFull <- Imm$MoralConv
Imm$ImmPersonalSalience <- Imm$Salience
Imm$ImmImportance <- Imm$Importance
Imm$ImmExtremity <- Imm$AttitudeEx
Imm$ImmTreat <- Imm$Treat

# Fit SUR Mods #
library(systemfit)

e1 <- ImmMoralFull ~ ImmTreat
e2 <- ImmPersonalSalience ~ ImmTreat
e3 <- ImmImportance ~ ImmTreat
e4 <- ImmExtremity ~ ImmTreat

SURVars <- c("ImmMoralFull", "ImmImportance", "ImmPersonalSalience",
             "ImmExtremity", "ImmTreat")

ExpData1 <- Imm[SURVars]
ExpData1 <- na.omit(ExpData1)

fitsur <- systemfit(list(Moral = e1, PerSal = e2, Imp = e3, Ext = e4), 
                    data=ExpData1)
summary(fitsur)

library(car)
rest1 <- "Moral_ImmTreat - PerSal_ImmTreat"
linearHypothesis(fitsur, rest1, test = "F")

rest2 <- "Moral_ImmTreat - Imp_ImmTreat"
linearHypothesis(fitsur, rest2, test = "F")

rest3 <- "Moral_ImmTreat - Ext_ImmTreat"
linearHypothesis(fitsur, rest3, test = "F")

### Conditioned by agree/disagree ###

e5 <- ImmMoralFull ~ ImmTreat*ImmAgree
e6 <- ImmPersonalSalience ~ ImmTreat*ImmAgree
e7 <- ImmImportance ~ ImmTreat*ImmAgree
e8 <- ImmExtremity ~ ImmTreat*ImmAgree

SURVars2 <- c("ImmMoralFull", "ImmImportance", "ImmPersonalSalience",
              "ImmExtremity", "ImmTreat", "ImmAgree")

ExpData2 <- Imm[SURVars2]
ExpData3 <- na.omit(ExpData2)

fitsur2 <- systemfit(list(Moral = e5, PerSal = e6, Imp = e7, Ext = e8), 
                     data=ExpData3)
summary(fitsur2)

# Coding for Mediation Analyses #

Imm$Ind <- 0
Imm$Ind[Imm$Q20.1 == 3] <- 1
Imm$Ind[Imm$Q20.1 == 4] <- 1

Imm$Dem <- 0
Imm$Dem[Imm$Q20.1 == 1] <- 1

Imm$Rep <- 0
Imm$Rep[Imm$Q20.1 == 2] <- 1

table(Imm$Q24)
Imm$Ideol <- Imm$Q24

table(Imm$Q25)
Imm$Female <- NA
Imm$Female[Imm$Q25 == 1] <- 0
Imm$Female[Imm$Q25 == 2] <- 1

table(Imm$Q26)
Imm$Age <- Imm$Q26

vars <- c("MoralConv", "Treat", "Anger", "Disgust", "Sadness", "Anxiety",
          "Ind", "Dem", "Rep", "Ideol", "Female", "Age", "AllEmo", "AttitudeEx",
          "Importance", "Salience")

Imm <- Imm[vars]
Imm <- na.omit(Imm)

Imm$ImmMoralFull <- Imm$MoralConv
Imm$ImmTreat <- Imm$Treat
Imm$ImmExtremity <- Imm$AttitudeEx
Imm$ImmPersonalSalience <- Imm$Salience
Imm$ImmImportance <- Imm$Importance
MedData <- Imm

library(mediation)

set.seed(12345)
med.fit.emo <- lm(AllEmo ~ ImmTreat + Dem + Rep + Ideol + Female + Age, 
                  data = MedData)
out.fit.emo <- lm(ImmMoralFull ~ AllEmo + ImmTreat + Dem + Rep + 
                    Ideol + Age + ImmExtremity + ImmImportance +
                    ImmPersonalSalience, data = MedData)
med.out.emo <- mediate(med.fit.emo, out.fit.emo, treat = "ImmTreat",
                       mediator = "AllEmo", robustSE = TRUE, 
                       sims = 2000)
summary(med.out.emo)

set.seed(12345)
med.fit.emo <- lm(AllEmo ~ ImmTreat + Dem + Rep + Ideol + Female + Age, 
                  data = MedData)
out.fit.emo <- lm(ImmExtremity ~ AllEmo + ImmTreat + Dem + Rep + 
                    Ideol + Age + ImmMoralFull + ImmImportance +
                    ImmPersonalSalience, data = MedData)
med.out.emo <- mediate(med.fit.emo, out.fit.emo, treat = "ImmTreat",
                       mediator = "AllEmo", robustSE = TRUE, 
                       sims = 2000)
summary(med.out.emo)

set.seed(12345)
med.fit.emo <- lm(AllEmo ~ ImmTreat + Dem + Rep + Ideol + Female + Age, 
                  data = MedData)
out.fit.emo <- lm(ImmImportance ~ AllEmo + ImmTreat + Dem + Rep + 
                    Ideol + Age + ImmExtremity + ImmMoralFull +
                    ImmPersonalSalience, data = MedData)
med.out.emo <- mediate(med.fit.emo, out.fit.emo, treat = "ImmTreat",
                       mediator = "AllEmo", robustSE = TRUE, 
                       sims = 2000)
summary(med.out.emo)

set.seed(12345)
med.fit.emo <- lm(AllEmo ~ ImmTreat + Dem + Rep + Ideol + Female + Age, 
                  data = MedData)
out.fit.emo <- lm(ImmPersonalSalience ~ AllEmo + ImmTreat + Dem + Rep + 
                    Ideol + Age + ImmExtremity + ImmImportance +
                    ImmMoralFull, data = MedData)
med.out.emo <- mediate(med.fit.emo, out.fit.emo, treat = "ImmTreat",
                       mediator = "AllEmo", robustSE = TRUE, 
                       sims = 2000)
summary(med.out.emo)

### Multiple Mediators (Supp Material) ###

MedData$ImmSalience <- MedData$ImmPersonalSalience

# Anger #
set.seed(12345)
m.med_anger_moralconv95 <- multimed(outcome = "ImmMoralFull", med.main = "Anger",
                                    med.alt = c("Disgust", "Sadness", "Anxiety"),
                                    treat = "ImmTreat",
                                    covariates = c("ImmExtremity", "ImmImportance",
                                                   "ImmSalience",
                                                   "Dem", "Rep", "Ideol", 
                                                   "Female", "Age"),
                                    data = MedData, sims = 2000,
                                    conf.level = .95)
summary(m.med_anger_moralconv95)

set.seed(12345)
m.med_anger_moralconv99 <- multimed(outcome = "ImmMoralFull", med.main = "Anger",
                                    med.alt = c("Disgust", "Sadness", "Anxiety"),
                                    treat = "ImmTreat",
                                    covariates = c("ImmExtremity", "ImmImportance",
                                                   "ImmSalience",
                                                   "Dem", "Rep", "Ideol", 
                                                   "Female", "Age"),
                                    data = MedData, sims = 2000,
                                    conf.level = .99)
summary(m.med_anger_moralconv99)

# Disgust #
set.seed(12345)
m.med_disgust_moralconv95 <- multimed(outcome = "ImmMoralFull", med.main = "Disgust",
                                      med.alt = c("Anger", "Sadness", "Anxiety"),
                                      treat = "ImmTreat",
                                      covariates = c("ImmExtremity", "ImmImportance",
                                                     "ImmSalience",
                                                     "Dem", "Rep", "Ideol", 
                                                     "Female", "Age"),
                                      data = MedData, sims = 2000,
                                      conf.level = .95)
summary(m.med_disgust_moralconv95)

set.seed(12345)
m.med_disgust_moralconv99 <- multimed(outcome = "ImmMoralFull", med.main = "Disgust",
                                      med.alt = c("Anger", "Sadness", "Anxiety"),
                                      treat = "ImmTreat",
                                      covariates = c("ImmExtremity", "ImmImportance",
                                                     "ImmSalience",
                                                     "Dem", "Rep", "Ideol", 
                                                     "Female", "Age"),
                                      data = MedData, sims = 2000,
                                      conf.level = .99)
summary(m.med_disgust_moralconv99)


# Anxiety #
set.seed(12345)
m.med_anxiety_moralconv95 <- multimed(outcome = "ImmMoralFull", med.main = "Anxiety",
                                      med.alt = c("Anger", "Sadness", "Disgust"),
                                      treat = "ImmTreat",
                                      covariates = c("ImmExtremity", "ImmImportance",
                                                     "ImmSalience",
                                                     "Dem", "Rep", "Ideol", 
                                                     "Female", "Age"),
                                      data = MedData, sims = 2000,
                                      conf.level = .95)
summary(m.med_anxiety_moralconv95)

set.seed(12345)
m.med_anxiety_moralconv99 <- multimed(outcome = "ImmMoralFull", med.main = "Anxiety",
                                      med.alt = c("Anger", "Sadness", "Disgust"),
                                      treat = "ImmTreat",
                                      covariates = c("ImmExtremity", "ImmImportance",
                                                     "ImmSalience",
                                                     "Dem", "Rep", "Ideol", 
                                                     "Female", "Age"),
                                      data = MedData, sims = 2000,
                                      conf.level = .99)
summary(m.med_anxiety_moralconv99)

# Sadness #
set.seed(12345)
m.med_sadness_moralconv95 <- multimed(outcome = "ImmMoralFull", med.main = "Sadness",
                                      med.alt = c("Anger", "Anxiety", "Disgust"),
                                      treat = "ImmTreat",
                                      covariates = c("ImmExtremity", "ImmImportance",
                                                     "ImmSalience",
                                                     "Dem", "Rep", "Ideol", 
                                                     "Female", "Age"),
                                      data = MedData, sims = 2000,
                                      conf.level = .95)
summary(m.med_sadness_moralconv95)

set.seed(12345)
m.med_sadness_moralconv99 <- multimed(outcome = "ImmMoralFull", med.main = "Sadness",
                                      med.alt = c("Anger", "Anxiety", "Disgust"),
                                      treat = "ImmTreat",
                                      covariates = c("ImmExtremity", "ImmImportance",
                                                     "ImmSalience",
                                                     "Dem", "Rep", "Ideol", 
                                                     "Female", "Age"),
                                      data = MedData, sims = 2000,
                                      conf.level = .99)
summary(m.med_sadness_moralconv99)


## Fear #
#set.seed(12345)
#m.med_fear_moralconv95 <- multimed(outcome = "ImmMoralFull", med.main = "Fear",
#                                   med.alt = c("Anger", "Anxiety", "Disgust", "Sadness"),
#                                   treat = "ImmTreat",
#                                   covariates = c("ImmExtremity", "ImmImportance",
#                                                  "ImmSalience",
#                                                  "Dem", "Rep", "Ideol", 
#                                                  "Female", "Age"),
#                                   data = MedData, sims = 2000,
#                                   conf.level = .95)
#summary(m.med_fear_moralconv95)
#
#set.seed(12345)
#m.med_fear_moralconv99 <- multimed(outcome = "ImmMoralFull", med.main = "Fear",
#                                   med.alt = c("Anger", "Anxiety", "Disgust", "Sadness"),
#                                   treat = "ImmTreat",
#                                   covariates = c("ImmExtremity", "ImmImportance",
#                                                  "ImmSalience",
#                                                  "Dem", "Rep", "Ideol", 
#                                                  "Female", "Age"),
#                                   data = MedData, sims = 2000,
#                                   conf.level = .99)
#summary(m.med_fear_moralconv99)


### Personal Salience ###

## PICK UP HERE ##

# Anger #
set.seed(12345)
m.med_anger_persal95 <- multimed(outcome = "ImmSalience", med.main = "Anger",
                                 med.alt = c("Disgust", "Sadness", "Anxiety"),
                                 treat = "ImmTreat",
                                 covariates = c("ImmExtremity", "ImmImportance",
                                                "ImmMoralFull",
                                                "Dem", "Rep", "Ideol", 
                                                "Female", "Age"),
                                 data = MedData, sims = 2000,
                                 conf.level = .95)
summary(m.med_anger_persal95)

set.seed(12345)
m.med_anger_persal99 <- multimed(outcome = "ImmSalience", med.main = "Anger",
                                 med.alt = c("Disgust", "Sadness", "Anxiety", "Fear"),
                                 treat = "ImmTreat",
                                 covariates = c("ImmExtremity", "ImmImportance",
                                                "ImmMoralFull",
                                                "Dem", "Rep", "Ideol", 
                                                "Female", "Age"),
                                 data = MedData, sims = 2000,
                                 conf.level = .99)
summary(m.med_anger_persal99)

# Disgust #
set.seed(12345)
m.med_disgust_persal95 <- multimed(outcome = "ImmSalience", med.main = "Disgust",
                                   med.alt = c("Anger", "Sadness", "Anxiety"),
                                   treat = "ImmTreat",
                                   covariates = c("ImmExtremity", "ImmImportance",
                                                  "ImmMoralFull",
                                                  "Dem", "Rep", "Ideol", 
                                                  "Female", "Age"),
                                   data = MedData, sims = 2000,
                                   conf.level = .95)
summary(m.med_disgust_persal95)

set.seed(12345)
m.med_disgust_persal99 <- multimed(outcome = "ImmSalience", med.main = "Disgust",
                                   med.alt = c("Anger", "Sadness", "Anxiety", "Fear"),
                                   treat = "ImmTreat",
                                   covariates = c("ImmExtremity", "ImmImportance",
                                                  "ImmMoralFull",
                                                  "Dem", "Rep", "Ideol", 
                                                  "Female", "Age"),
                                   data = MedData, sims = 2000,
                                   conf.level = .99)
summary(m.med_disgust_persal99)

# Anxiety #
set.seed(12345)
m.med_anxiety_persal95 <- multimed(outcome = "ImmSalience", med.main = "Anxiety",
                                   med.alt = c("Anger", "Sadness", "Disgust"),
                                   treat = "ImmTreat",
                                   covariates = c("ImmExtremity", "ImmImportance",
                                                  "ImmMoralFull",
                                                  "Dem", "Rep", "Ideol", 
                                                  "Female", "Age"),
                                   data = MedData, sims = 2000,
                                   conf.level = .95)
summary(m.med_anxiety_persal95)

set.seed(12345)
m.med_anxiety_persal99 <- multimed(outcome = "ImmSalience", med.main = "Anxiety",
                                   med.alt = c("Anger", "Sadness", "Disgust", "Fear"),
                                   treat = "ImmTreat",
                                   covariates = c("ImmExtremity", "ImmImportance",
                                                  "ImmMoralFull",
                                                  "Dem", "Rep", "Ideol", 
                                                  "Female", "Age"),
                                   data = MedData, sims = 2000,
                                   conf.level = .99)
summary(m.med_anxiety_persal99)

# Sadness #
set.seed(12345)
m.med_sadness_persal95 <- multimed(outcome = "ImmSalience", med.main = "Sadness",
                                   med.alt = c("Anger", "Anxiety", "Disgust"),
                                   treat = "ImmTreat",
                                   covariates = c("ImmExtremity", "ImmImportance",
                                                  "ImmMoralFull",
                                                  "Dem", "Rep", "Ideol", 
                                                  "Female", "Age"),
                                   data = MedData, sims = 2000,
                                   conf.level = .95)
summary(m.med_sadness_persal95)

set.seed(12345)
m.med_sadness_persal99 <- multimed(outcome = "ImmSalience", med.main = "Sadness",
                                   med.alt = c("Anger", "Anxiety", "Disgust", "Fear"),
                                   treat = "ImmTreat",
                                   covariates = c("ImmExtremity", "ImmImportance",
                                                  "ImmMoralFull",
                                                  "Dem", "Rep", "Ideol", 
                                                  "Female", "Age"),
                                   data = MedData, sims = 2000,
                                   conf.level = .99)
summary(m.med_sadness_persal99)


# Fear #
#set.seed(12345)
#m.med_fear_persal95 <- multimed(outcome = "ImmSalience", med.main = "Fear",
#                                med.alt = c("Anger", "Anxiety", "Disgust", "Sadness"),
#                                treat = "ImmTreat",
#                                covariates = c("ImmExtremity", "ImmImportance",
#                                               "ImmMoralFull",
#                                               "Dem", "Rep", "Ideol", 
#                                               "Female", "Age"),
#                                data = MedData, sims = 2000,
#                                conf.level = .95)
#summary(m.med_fear_persal95)
#
#set.seed(12345)
#m.med_fear_persal99 <- multimed(outcome = "ImmSalience", med.main = "Fear",
#                                med.alt = c("Anger", "Anxiety", "Disgust", "Sadness"),
#                                treat = "ImmTreat",
#                                covariates = c("ImmExtremity", "ImmImportance",
#                                               "ImmMoralFull",
#                                               "Dem", "Rep", "Ideol", 
#                                               "Female", "Age"),
#                                data = MedData, sims = 2000,
#                                conf.level = .99)
#summary(m.med_fear_persal99)
#

### Attitude Importance ###

# Anger #
set.seed(12345)
m.med_anger_imp95 <- multimed(outcome = "ImmImportance", med.main = "Anger",
                              med.alt = c("Disgust", "Sadness", "Anxiety"),
                              treat = "ImmTreat",
                              covariates = c("ImmExtremity", "ImmSalience",
                                             "ImmMoralFull",
                                             "Dem", "Rep", "Ideol", 
                                             "Female", "Age"),
                              data = MedData, sims = 2000,
                              conf.level = .95)
summary(m.med_anger_imp95)

set.seed(12345)
m.med_anger_imp99 <- multimed(outcome = "ImmImportance", med.main = "Anger",
                              med.alt = c("Disgust", "Sadness", "Anxiety", "Fear"),
                              treat = "ImmTreat",
                              covariates = c("ImmExtremity", "ImmSalience",
                                             "ImmMoralFull",
                                             "Dem", "Rep", "Ideol", 
                                             "Female", "Age"),
                              data = MedData, sims = 2000,
                              conf.level = .99)
summary(m.med_anger_imp99)

# Disgust #
set.seed(12345)
m.med_disgust_imp95 <- multimed(outcome = "ImmImportance", med.main = "Disgust",
                                med.alt = c("Anger", "Sadness", "Anxiety"),
                                treat = "ImmTreat",
                                covariates = c("ImmExtremity", "ImmSalience",
                                               "ImmMoralFull",
                                               "Dem", "Rep", "Ideol", 
                                               "Female", "Age"),
                                data = MedData, sims = 2000,
                                conf.level = .95)
summary(m.med_disgust_imp95)

set.seed(12345)
m.med_disgust_imp99 <- multimed(outcome = "ImmImportance", med.main = "Disgust",
                                med.alt = c("Anger", "Sadness", "Anxiety", "Fear"),
                                treat = "ImmTreat",
                                covariates = c("ImmExtremity", "ImmSalience",
                                               "ImmMoralFull",
                                               "Dem", "Rep", "Ideol", 
                                               "Female", "Age"),
                                data = MedData, sims = 2000,
                                conf.level = .99)
summary(m.med_disgust_imp99)

# Anxiety #
set.seed(12345)
m.med_anxiety_imp95 <- multimed(outcome = "ImmImportance", med.main = "Anxiety",
                                med.alt = c("Anger", "Sadness", "Disgust"),
                                treat = "ImmTreat",
                                covariates = c("ImmExtremity", "ImmSalience",
                                               "ImmMoralFull",
                                               "Dem", "Rep", "Ideol", 
                                               "Female", "Age"),
                                data = MedData, sims = 2000,
                                conf.level = .95)
summary(m.med_anxiety_imp95)

set.seed(12345)
m.med_anxiety_imp99 <- multimed(outcome = "ImmImportance", med.main = "Anxiety",
                                med.alt = c("Anger", "Sadness", "Disgust", "Fear"),
                                treat = "ImmTreat",
                                covariates = c("ImmExtremity", "ImmSalience",
                                               "ImmMoralFull",
                                               "Dem", "Rep", "Ideol", 
                                               "Female", "Age"),
                                data = MedData, sims = 2000,
                                conf.level = .99)
summary(m.med_anxiety_imp99)

# Sadness #
set.seed(12345)
m.med_sadness_imp95 <- multimed(outcome = "ImmImportance", med.main = "Sadness",
                                med.alt = c("Anger", "Anxiety", "Disgust"),
                                treat = "ImmTreat",
                                covariates = c("ImmExtremity", "ImmSalience",
                                               "ImmMoralFull",
                                               "Dem", "Rep", "Ideol", 
                                               "Female", "Age"),
                                data = MedData, sims = 2000,
                                conf.level = .95)
summary(m.med_sadness_imp95)

set.seed(12345)
m.med_sadness_imp99 <- multimed(outcome = "ImmImportance", med.main = "Sadness",
                                med.alt = c("Anger", "Anxiety", "Disgust", "Fear"),
                                treat = "ImmTreat",
                                covariates = c("ImmExtremity", "ImmSalience",
                                               "ImmMoralFull",
                                               "Dem", "Rep", "Ideol", 
                                               "Female", "Age"),
                                data = MedData, sims = 2000,
                                conf.level = .99)
summary(m.med_sadness_imp99)

# Fear #
#set.seed(12345)
#m.med_fear_imp95 <- multimed(outcome = "ImmImportance", med.main = "Fear",
#                             med.alt = c("Anger", "Anxiety", "Disgust", "Sadness"),
#                             treat = "ImmTreat",
#                             covariates = c("ImmExtremity", "ImmSalience",
#                                            "ImmMoralFull",
#                                            "Dem", "Rep", "Ideol", 
#                                            "Female", "Age"),
#                             data = MedData, sims = 2000,
#                             conf.level = .95)
#summary(m.med_fear_imp95)
#
#set.seed(12345)
#m.med_fear_imp99 <- multimed(outcome = "ImmImportance", med.main = "Fear",
#                             med.alt = c("Anger", "Anxiety", "Disgust", "Sadness"),
#                             treat = "ImmTreat",
#                             covariates = c("ImmExtremity", "ImmSalience",
#                                            "ImmMoralFull",
#                                            "Dem", "Rep", "Ideol", 
#                                            "Female", "Age"),
#                             data = MedData, sims = 2000,
#                             conf.level = .99)
#summary(m.med_fear_imp99)


# Attitude Extremity #

# Anger #
set.seed(12345)
m.med_anger_ext95 <- multimed(outcome = "ImmExtremity", med.main = "Anger",
                              med.alt = c("Disgust", "Sadness", "Anxiety"),
                              treat = "ImmTreat",
                              covariates = c("ImmImportance", "ImmSalience",
                                             "ImmMoralFull",
                                             "Dem", "Rep", "Ideol", 
                                             "Female", "Age"),
                              data = MedData, sims = 2000,
                              conf.level = .95)
summary(m.med_anger_ext95)

set.seed(12345)
m.med_anger_ext99 <- multimed(outcome = "ImmExtremity", med.main = "Anger",
                              med.alt = c("Disgust", "Sadness", "Anxiety"),
                              treat = "ImmTreat",
                              covariates = c("ImmImportance", "ImmSalience",
                                             "ImmMoralFull",
                                             "Dem", "Rep", "Ideol", 
                                             "Female", "Age"),
                              data = MedData, sims = 2000,
                              conf.level = .99)
summary(m.med_anger_ext99)

# Disgust #
set.seed(12345)
m.med_disgust_ext95 <- multimed(outcome = "ImmExtremity", med.main = "Disgust",
                                med.alt = c("Anger", "Sadness", "Anxiety"),
                                treat = "ImmTreat",
                                covariates = c("ImmImportance", "ImmSalience",
                                               "ImmMoralFull",
                                               "Dem", "Rep", "Ideol", 
                                               "Female", "Age"),
                                data = MedData, sims = 2000,
                                conf.level = .95)
summary(m.med_disgust_ext95)

set.seed(12345)
m.med_disgust_ext99 <- multimed(outcome = "ImmExtremity", med.main = "Disgust",
                                med.alt = c("Anger", "Sadness", "Anxiety"),
                                treat = "ImmTreat",
                                covariates = c("ImmImportance", "ImmSalience",
                                               "ImmMoralFull",
                                               "Dem", "Rep", "Ideol", 
                                               "Female", "Age"),
                                data = MedData, sims = 2000,
                                conf.level = .99)
summary(m.med_disgust_ext99)

# Anxiety #
set.seed(12345)
m.med_anxiety_ext95 <- multimed(outcome = "ImmExtremity", med.main = "Anxiety",
                                med.alt = c("Anger", "Sadness", "Disgust"),
                                treat = "ImmTreat",
                                covariates = c("ImmImportance", "ImmSalience",
                                               "ImmMoralFull",
                                               "Dem", "Rep", "Ideol", 
                                               "Female", "Age"),
                                data = MedData, sims = 2000,
                                conf.level = .95)
summary(m.med_anxiety_ext95)

set.seed(12345)
m.med_anxiety_ext99 <- multimed(outcome = "ImmExtremity", med.main = "Anxiety",
                                med.alt = c("Anger", "Sadness", "Disgust"),
                                treat = "ImmTreat",
                                covariates = c("ImmImportance", "ImmSalience",
                                               "ImmMoralFull",
                                               "Dem", "Rep", "Ideol", 
                                               "Female", "Age"),
                                data = MedData, sims = 2000,
                                conf.level = .99)
summary(m.med_anxiety_ext99)

# Sadness #
set.seed(12345)
m.med_sadness_ext95 <- multimed(outcome = "ImmExtremity", med.main = "Sadness",
                                med.alt = c("Anger", "Anxiety", "Disgust"),
                                treat = "ImmTreat",
                                covariates = c("ImmImportance", "ImmSalience",
                                               "ImmMoralFull",
                                               "Dem", "Rep", "Ideol", 
                                               "Female", "Age"),
                                data = MedData, sims = 2000,
                                conf.level = .95)
summary(m.med_sadness_ext95)

set.seed(12345)
m.med_sadness_ext99 <- multimed(outcome = "ImmExtremity", med.main = "Sadness",
                                med.alt = c("Anger", "Anxiety", "Disgust"),
                                treat = "ImmTreat",
                                covariates = c("ImmImportance", "ImmSalience",
                                               "ImmMoralFull",
                                               "Dem", "Rep", "Ideol", 
                                               "Female", "Age"),
                                data = MedData, sims = 2000,
                                conf.level = .99)
summary(m.med_sadness_ext99)


## Fear #
#set.seed(12345)
#m.med_fear_ext95 <- multimed(outcome = "ImmExtremity", med.main = "Fear",
#                             med.alt = c("Anger", "Anxiety", "Disgust", "Sadness"),
#                             treat = "ImmTreat",
#                             covariates = c("ImmImportance", "ImmSalience",
#                                            "ImmMoralFull",
#                                            "Dem", "Rep", "Ideol", 
#                                            "Female", "Age"),
#                             data = MedData, sims = 2000,
#                             conf.level = .95)
#summary(m.med_fear_ext95)
#
#set.seed(12345)
#m.med_fear_ext99 <- multimed(outcome = "ImmExtremity", med.main = "Fear",
#                             med.alt = c("Anger", "Anxiety", "Disgust", "Sadness"),
#                             treat = "ImmTreat",
#                             covariates = c("ImmImportance", "ImmSalience",
#                                            "ImmMoralFull",
#                                            "Dem", "Rep", "Ideol", 
#                                            "Female", "Age"),
#                             data = MedData, sims = 2000,
#                             conf.level = .99)
#summary(m.med_fear_ext99)

